package com.lan.schedule;

//import sun.misc.BASE64Decoder;
//import sun.misc.BASE64Encoder;

import Decoder.BASE64Decoder;
import Decoder.BASE64Encoder;

/**
 * 基于Base64的加密和解密工具类
 */
public class Base64EncodeUtils {

    /**
     * 示例使用
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        String str = "20200441033";
        String pass = "ljp15121512";
        String username = encryptBASE64(str.getBytes());
        String password = encryptBASE64(pass.getBytes());
        System.out.println(username+"%%%"+password);


    }



    /**
     * BASE64解密
     * @throws Exception
     */
    public static byte[] decryptBASE64(String key) throws Exception {
        return (new BASE64Decoder()).decodeBuffer(key);
    }

    /**
     * BASE64加密
     */
    public static String encryptBASE64(byte[] key) throws Exception {
        return (new BASE64Encoder()).encodeBuffer(key);
    }

}

